﻿//-----------------------------------------------------------------------
// <copyright file="ScheduleTest.cs" company="FastNET Services">
//     Copyright (c) 2008-2009. All Rights Reserved.
// </copyright>
// <license>
//     GPLv2
// </license>
// <warranty>
//     THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING
//     BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
//     NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM,
//     DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
//     OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
// </warranty>
//-----------------------------------------------------------------------
#region Usings
using System;
using FastNET.CleanAct.Client.ManagerEngineData.Entities;
using FastNET.CleanAct.Common.Repository.Interfaces.DataInterfaces.ManagementEngine;
using Microsoft.VisualStudio.TestTools.UnitTesting;
#endregion

namespace FastNET.CleanAct.Testing.Client.ManagerEngineData.Entities
{
    /// <summary>
    /// Unit Tests for ScheduleTest
    /// </summary>
    [TestClass]
    public class ScheduleTest
    {
        /// <summary>
        /// Gets or sets the test context which provides
        /// information about and functionality for the current test run.
        /// </summary>
        public TestContext TestContext { get; set; }

        #region Name Validation

        /// <summary>
        /// Test for Name being Null
        /// </summary>
        [TestMethod]
        [ExpectedException(typeof(ArgumentNullException))]
        public void Name_Null()
        {
            new Schedule { Name = null };
        }

        /// <summary>
        /// Test for Name being Too Long
        /// </summary>
        [TestMethod]
        [ExpectedException(typeof(ArgumentOutOfRangeException))]
        public void Name_TooLong()
        {
            new Schedule { Name = string.Empty.PadRight(101, 'A') };
        }

        /// <summary>
        /// Test for Name being successful
        /// </summary>
        [TestMethod]
        public void Name_Success()
        {
            IScheduleData data = new Schedule { Name = "TestName" };
            Assert.AreEqual("TestName", data.Name, "Mismatched Data");
        }

        /// <summary>
        /// Test for Name being defaulted
        /// </summary>
        [TestMethod]
        public void Name_Default()
        {
            IScheduleData data = new Schedule();
            Assert.AreEqual(null, data.Name, "Mismatched Data");
        }

        #endregion

        #region Value Validation

        /// <summary>
        /// Test for Value being Null
        /// </summary>
        [TestMethod]
        [ExpectedException(typeof(ArgumentNullException))]
        public void Value_Null()
        {
            new Schedule { Value = null };
        }

        /// <summary>
        /// Test for Value being Too Long
        /// </summary>
        [TestMethod]
        [ExpectedException(typeof(ArgumentOutOfRangeException))]
        public void Value_TooLong()
        {
            new Schedule { Value = string.Empty.PadRight(4001, 'A') };
        }

        /// <summary>
        /// Test for Value being successful
        /// </summary>
        [TestMethod]
        public void Value_Success()
        {
            IScheduleData data = new Schedule { Value = "TestName" };
            Assert.AreEqual("TestName", data.Value, "Mismatched Data");
        }

        /// <summary>
        /// Test for Value being defaulted
        /// </summary>
        [TestMethod]
        public void Value_Default()
        {
            IScheduleData data = new Schedule();
            Assert.AreEqual(null, data.Value, "Mismatched Data");
        }

        #endregion

        #region Enabled Validation

        /// <summary>
        /// Test for Enabled being successful
        /// </summary>
        [TestMethod]
        public void Enabled_Success()
        {
            IScheduleData data = new Schedule { Enabled = true };
            Assert.AreEqual(true, data.Enabled, "Mismatched Data");
        }

        /// <summary>
        /// Test for Enabled being defaulted
        /// </summary>
        [TestMethod]
        public void Enabled_Default()
        {
            IScheduleData data = new Schedule();
            Assert.AreEqual(false, data.Enabled, "Mismatched Data");
        }

        #endregion

        #region TemplateID Validation

        /// <summary>
        /// Test for TemplateID being successful
        /// </summary>
        [TestMethod]
        public void TemplateID_Success()
        {
            Guid value = Guid.NewGuid();
            IScheduleData data = new Schedule { TemplateID = value };
            Assert.AreEqual(value.ToString(), data.TemplateID.ToString(), "Mismatched Data");
        }

        #endregion

        #region CreatedDate Validation

        /// <summary>
        /// Test for CreatedDate being successful
        /// </summary>
        [TestMethod]
        public void CreatedDate_Success()
        {
            DateTime value = DateTime.UtcNow;
            IScheduleData data = new Schedule { CreatedDate = value };
            Assert.AreEqual(value, data.CreatedDate, "Mismatched Data");
        }

        /// <summary>
        /// Test for CreatedDate being defaulted
        /// </summary>
        [TestMethod]
        public void CreatedDate_Default()
        {
            IScheduleData data = new Schedule();
            Assert.AreEqual(DateTime.MinValue, data.CreatedDate, "Mismatched Data");
        }

        #endregion

        #region ModifiedDate Validation

        /// <summary>
        /// Test for ModifiedDate being successful
        /// </summary>
        [TestMethod]
        public void ModifiedDate_Success()
        {
            DateTime value = DateTime.UtcNow;
            IScheduleData data = new Schedule { ModifiedDate = value };
            Assert.AreEqual(value, data.ModifiedDate, "Mismatched Data");
        }

        /// <summary>
        /// Test for ModifiedDate being defaulted
        /// </summary>
        [TestMethod]
        public void ModifiedDate_Default()
        {
            IScheduleData data = new Schedule();
            Assert.AreEqual(DateTime.MinValue, data.ModifiedDate, "Mismatched Data");
        }

        #endregion
    }
}
